package struts3.util;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import struts3.form.ActionForm;

public class FullBean {

	public FullBean(){}
	
	public static ActionForm getBean(String classpath,HttpServletRequest request){
		
		ActionForm form = null;
		
		try{
			Class clazz = Class.forName(classpath);
			form = (ActionForm) clazz.newInstance();
			Field [] field_arr = clazz.getDeclaredFields();
			for(Field f : field_arr)
			{
				f.setAccessible(true);
				f.set(form, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
			
		}catch (Exception e) {
			e.printStackTrace();
			System.out.println("严重：Form创建失败。。。。。！！");
		}
		
		return form;
	}
}
